package cn.lesaas.esb.poc.mock;

import java.io.InputStream;

import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.util.ExchangeHelper;

public class VBSRoute extends RouteBuilder {

	@Override
	public void configure() throws Exception {
		from("netty4:tcp://172.16.100.41:59999?allowDefaultCodec=false&encoder=#stringEncoder&decoder=#stringDecoder")
				.startupOrder(10).to("log:VBS?showAll=true").process(new Processor() {
					@Override
					public void process(Exchange exchange) throws Exception {
						final InputStream resource = getClass().getClassLoader().getResourceAsStream("resp.xml");
						final String resp = ExchangeHelper.convertToMandatoryType(exchange, String.class, resource);
						exchange.getIn().setBody(resp, String.class);
					}
				});
	}
}
